package com.xiaoma.lock.notReentrancelock;

/**
 * @author xiaomacdut
 * @date 2020年3月24日 下午4:12:39
 */
public class Count{
    
    private Lock lock;
    
    /**
     * 
     */
    public Count(Lock lock){
        this.lock = lock;
    }
    
    public void print() throws InterruptedException{
        lock.lock();
        doAdd();
        lock.unlock();
    }
    
    public void doAdd() throws InterruptedException{
        lock.lock();
        // do something
        lock.unlock();
    }
    
}
